package o;

import android.content.Context;
import android.content.IntentFilter;
import com.huawei.secure.android.common.intent.SafeIntent;
import com.huawei.updatesdk.service.otaupdate.UpdateKey;

public abstract class edh {
    public static edj ˋ(Context context) {
        edj o_edj = new edj();
        try {
            SafeIntent safeIntent = new SafeIntent(context.registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED")));
            int intExtra = safeIntent.getIntExtra(UpdateKey.STATUS, 1);
            if (intExtra == 2 || intExtra == 5) {
                o_edj.ॱ = true;
                Logger.ˎ("BatteryUtil", "get battery:" + o_edj.toString());
                return o_edj;
            }
            o_edj.ॱ = false;
            o_edj.ˎ = (safeIntent.getIntExtra("level", 0) * 100) / safeIntent.getIntExtra("scale", 100);
            Logger.ˎ("BatteryUtil", "get battery:" + o_edj.toString());
            return o_edj;
        } catch (SecurityException e) {
            Logger.e("BatteryUtil", "register battery changed broadcast exception,e: " + e.toString() + ",and ignore the battery status...");
            o_edj.ॱ = true;
        }
    }
}
